import { defineStore } from 'pinia'
import { getStorage, setStorage } from '@/utils/storage'
import i18n from '@/lang'
console.log(i18n)
export const useLangStore = defineStore('lang', {
  state: () => ({
    lang: getStorage('language') || 'zh'
  }),
  actions: {
    updateLang(val) {
      //val： zh  en
      this.lang = val
      //  存储到本地
      setStorage('language', val)
      // 切换 国际化
      i18n.global.locale.value = val
      console.log(i18n.global.locale.value)
    }
  }
})
